package com.mxpio.erp.common.equipment.entity;

import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_EQUIPMENT")
@Schema(description="设备(类型)信息")
public class Equipment extends BaseEntity {

	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "EQP_CODE_", updatable = false)
	@Generator(policy = ResCodeGeneratorPolicy.class)
	@Schema(description = "设备编码")
	private String eqpCode;
	/**设备名称*/
	@Column(name = "EQP_NAME_")
	@Schema(description = "设备名称")
	private String eqpName;

	@Column(name = "SPEC_TYPE_")
	@Schema(description = "规格型号")
	private String specType;

	@Column(name = "EQP_TYPE_CODE_")
	@Schema(description = "设备分类编码")
	@Dict(dicCode="code", dicEntity = EquipmentCategory.class, dicText = "name")
	private String eqpTypeCode;

	@Column(name = "EQP_CLASS_")//增加设备类型
	@Schema(description = "设备类型")
	@Dict(dicCode = "ERP_EQUIPMENT_EQP_CLASS")
	private String eqpClass;

	@Column(name = "POWER_")
	@Schema(description = "设备功率")
	private String power;

	@Column(name = "MANUFACTURER_")
	@Schema(description = "制造商")
	@Dict(dicCode="pnCode", dicEntity = EquipmentManufacturer.class, dicText = "pnName")
	private String manufacturer;

	@Column(name = "REPAIR_GROUP_CODE_")
	@Schema(description = "维修群组")
	@Dict(dicCode="groupCode", dicEntity = EquipmentPersonGroup.class, dicText = "groupName")
	private String repairPersonGroupCode;

	@Column(name = "UPKEEP_GROUP_CODE_")
	@Schema(description = "保养群组")
	@Dict(dicCode="groupCode", dicEntity = EquipmentPersonGroup.class, dicText = "groupName")
	private String upkeepPersonGroupCode;

	@Column(name = "ENGINEER_GROUP_CODE_")
	@Schema(description = "工程师组")
	@Dict(dicCode="groupCode", dicEntity = EquipmentPersonGroup.class, dicText = "groupName")
	private String engineerPersonGroupCode;

	@Column(name = "CHECK_GROUP_CODE_")
	@Schema(description = "点检群组")
	@Dict(dicCode="groupCode", dicEntity = EquipmentPersonGroup.class, dicText = "groupName")
	private String checkPersonGroupCode;

	@Column(name = "INSPECT_DUTY_USER_")
	@Schema(description = "送检负责人")
	@Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
	private String inspectDutyUser;

	@Column(name = "IS_KEY_")
	@Schema(description = "是否关键设备")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private Integer isKey;

	@Column(name = "IS_ESA_")
	@Schema(description = "是否ESA设备")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private Integer isEsa;

	@Column(name = "IS_DIGITAL_")
	@Schema(description = "是否数控设备")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private Integer isDigital;

	@Column(name = "DIGITAL_CONTROL_")
	@Schema(description = "数控系统")
	@Dict(dicCode = "ERP_TECH_DIGITAL_CONTROL")//
	private String digitalControl;

	@Column(name = "IS_SUB_ORDINATE_")
	@Schema(description = "是否附属设备")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private Integer isSubOrdinate;

	@Column(name = "IS_CALIBRATE_")
	@Schema(description = "是否需要检定")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private Integer isCalibrate;

	@Column(name = "CALIBRATE_CYCLE_")
	@Schema(description = "检定周期(天)")
	private Integer calibrateCycle;

	@Column(name = "CALIBRATE_ADVANCE_")
	@Schema(description = "检定提前期(天)")//检定任务提前生成天数
	private Integer calibrateAdvance;

	@Column(name = "IMG_FILE_")
	@Schema(description = "图片路径")
	private String imgFile;

	@Transient
	private List<EquipmentBom> equipmentBomList;
}
